package com.wowangz.cms.systemmanage.duty.service;

import java.util.HashMap;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.wowangz.cms.syscore.exception.ServiceException;
import com.wowangz.cms.syscore.service.BaseService;
import com.wowangz.cms.systemmanage.duty.pojo.Duty;

public class DutyService extends BaseService{
	
	private Logger logger = LoggerFactory.getLogger(DutyService.class);

	/**
	 * 分页查询总条数
	 * 
	 */
	public long findResultCount(HashMap<String, Object> map) throws ServiceException {
		Long countNum = this.getSqlSession().selectOne("Duty.queryDutyCount", map);
		return countNum;
	}

	/**
	 * 查询记录集合
	 * 
	 */
	public List<Duty> findResultList(HashMap<String, Object> map) throws ServiceException {
		List<Duty> list = this.getSqlSession().selectList("Duty.queryDutyPage", map);
		return list;
	}
	
	
	/**
	 * 验证信息
	 */
	public boolean validationDuty(HashMap<String, Object> map) throws ServiceException {
		Long countNum = this.getSqlSession().selectOne("Duty.validationDuty", map);
		if(countNum != 0){
			return false;
		}else{
			return true;
		}
	}
	
	public void add(Duty duty) throws ServiceException{
		this.getSqlSession().insert("Duty.insertDuty", duty);
	}
	
	public Duty findDutyById(HashMap<String,Object> hashMap) throws ServiceException {
		Duty duty = this.getSqlSession().selectOne("Duty.findDutyById", hashMap);
		return duty;
	}
	
	public void update(Duty duty) throws ServiceException{
		this.getSqlSession().insert("Duty.updateDuty", duty);
	}
}
